package com.iman.manjusri.service.impl;

import java.util.ArrayList;
import java.util.List;

import javax.inject.Inject;

import org.springframework.stereotype.Service;

import com.iman.common.hibernate.HibernateSupport;
import com.iman.common.hibernate.TemplateQLService;
import com.iman.manjusri.domain.ProvinceCity;
import com.iman.manjusri.service.AreaService;

@Service("areaService")
public class AreaServiceImpl implements AreaService {

    @Inject
    TemplateQLService templateQLService;

    @Inject
    HibernateSupport  hibernateSupport;

    @Override
    public ArrayList getProvinceCityList() {
        @SuppressWarnings("unchecked")
        List<ProvinceCity> provinceList = (List<ProvinceCity>)hibernateSupport.find(" from ProvinceCity where level=1 or level=2");
        if (null != provinceList && provinceList.size() > 0) {
            return (ArrayList<ProvinceCity>) provinceList;
        }

        return null;
    }

    @Override
    public ArrayList<ProvinceCity> getProvinceList() {
      @SuppressWarnings("unchecked")
      List<ProvinceCity> provinceList = (List<ProvinceCity>)hibernateSupport.find(" from ProvinceCity where level=1 and parent_code=''");
      if (null != provinceList && provinceList.size() > 0) {
          return (ArrayList<ProvinceCity>) provinceList;
      }

      return null;
    }

    @Override
    public ArrayList getCityList() {
        return null;
    }

}
